Method and apparatus for supporting address translation in a virtual machine environment

ABSTRACT

In one embodiment, a method includes receiving control transitioned from a virtual machine (VM) due to a privileged event pertaining to a translation-lookaside buffer (TLB), and determining which entries in a guest translation data structure were modified by the VM. The determination is made based on metadata extracted from a shadow translation data structure maintained by a virtual machine monitor (VMM) and attributes associated with entries in the shadow translation data structure. The method further includes synchronizing entries in the shadow translation data structure that correspond to the modified entries in the guest translation data structure with the modified entries in the guest translation data structure.

FIELD

Embodiments of the invention relate generally to virtual machines, andmore specifically to supporting address translation in a virtual machineenvironment.

BACKGROUND

A conventional virtual-machine monitor (VMM) typically runs on acomputer and presents to other software the abstraction of one or morevirtual machines. Each virtual machine may function as a self-containedplatform, running its own “guest operating system” (i.e., an operatingsystem (OS) hosted by the VMM) and other software, collectively referredto as guest software. The guest software expects to operate as if itwere running on a dedicated computer rather than a virtual machine. Thatis, the guest software expects to control various events and have accessto hardware resources such as physical memory and memory-mappedinput/output (I/O) devices. For example, the guest software expects tomaintain control over address-translation operations and have theability to allocate physical memory, provide protection from and betweenguest applications, use a variety of paging techniques, etc. However, ina virtual-machine environment, the VMM should be able to have ultimatecontrol over the computer's resources to provide protection from andbetween virtual machines.

BRIEF DESCRIPTION OF THE DRAWINGS

The present invention is illustrated by way of example, and not by wayof limitation, in the figures of the accompanying drawings and in whichlike reference numerals refer to similar elements and in which:

FIG. 1 illustrates one embodiment of a virtual-machine environment, inwhich the present invention may operate;

FIG. 2 illustrates operation of a virtual TLB, according to oneembodiment of the present invention;

FIGS. 3A and 3B illustrate a process of creating and maintainingmetadata for a shadow PT hierarchy, according to two alternativeembodiments of the present invention;

FIG. 4 is a flow diagram of one embodiment of a process forsynchronizing guest translation data structure and shadow translationdata structure;

FIG. 5 is a flow diagram of one embodiment of a process for maintainingmetadata for a shadow translation data structure;

FIG. 6 is a flow diagram of one embodiment of a process for facilitatinga change of an address space;

FIG. 7 is a flow diagram of one embodiment of a process forsynchronizing entries of two translation data structures for a specifiedaddress;

FIG. 8 is a flow diagram of one embodiment of a process for removing ashadow PT hierarchy from a working set of shadow PT hierarchiesmaintained by the VMM;

FIG. 9 is a flow diagram of one embodiment of a process for adding anentry to a PD of a shadow PT hierarchy;

FIG. 10 is a flow diagram of one embodiment of a process for removing anentry from a PD of a shadow PT hierarchy;

FIG. 11 is a flow diagram of one embodiment of a process for adding anentry to a PT of a shadow PT hierarchy;

FIG. 12 is a flow diagram of one embodiment of a process for removing anentry from a PT of a shadow PT hierarchy;

FIG. 13 is a flow diagram of one embodiment of a process for monitoringa PTE of a shadow PT hierarchy; and

FIG. 14 is a flow diagram of one embodiment of a process for removingmonitoring from a PTE of a shadow PT hierarchy.

DESCRIPTION OF EMBODIMENTS

A method and apparatus for supporting address translation in a virtualmachine environment is described. In the following description, forpurposes of explanation, numerous specific details are set forth inorder to provide a thorough understanding of the present invention. Itwill be apparent, however, to one skilled in the art that the presentinvention can be practiced without these specific details.

Some portions of the detailed descriptions that follow are presented interms of algorithms and symbolic representations of operations on databits within a computer system's registers or memory. These algorithmicdescriptions and representations are the means used by those skilled inthe data processing arts to convey most effectively the substance oftheir work to others skilled in the art. An algorithm is here, andgenerally, conceived to be a self-consistent sequence of operationsleading to a desired result. The operations are those requiring physicalmanipulations of physical quantities. Usually, though not necessarily,these quantities take the form of electrical or magnetic signals capableof being stored, transferred, combined, compared, and otherwisemanipulated. It has proven convenient at times, principally for reasonsof common usage, to refer to these signals as bits, values, elements,symbols, characters, terms, numbers, or the like.

It should be borne in mind, however, that all of these and similar termsare to be associated with the appropriate physical quantities and aremerely convenient labels applied to these quantities. Unlessspecifically stated otherwise as apparent from the followingdiscussions, it is appreciated that throughout the present invention,discussions utilizing terms such as “processing” or “computing” or“calculating” or “determining” or the like, may refer to the action andprocesses of a computer system, or similar electronic computing device,that manipulates and transforms data represented as physical(electronic) quantities within the computer system's registers andmemories into other data similarly represented as physical quantitieswithin the computer-system memories or registers or other suchinformation storage, transmission or display devices.

In the following detailed description of the embodiments, reference ismade to the accompanying drawings that show, by way of illustration,specific embodiments in which the invention may be practiced. In thedrawings, like numerals describe substantially similar componentsthroughout the several views. These embodiments are described insufficient detail to enable those skilled in the art to practice theinvention. Other embodiments may be utilized and structural, logical,and electrical changes may be made without departing from the scope ofthe present invention. Moreover, it is to be understood that the variousembodiments of the invention, although different, are not necessarilymutually exclusive. For example, a particular feature, structure, orcharacteristic described in one embodiment may be included within otherembodiments. The following detailed description is, therefore, not to betaken in a limiting sense, and the scope of the present invention isdefined only by the appended claims, along with the full scope ofequivalents to which such claims are entitled.

Although the below examples may describe providing support for addresstranslation in a virtual machine environment in the context of executionunits and logic circuits, other embodiments of the present invention canbe accomplished by way of software. For example, in some embodiments,the present invention may be provided as a computer program product orsoftware which may include a machine or computer-readable medium havingstored thereon instructions which may be used to program a computer (orother electronic devices) to perform a process according to the presentinvention. In other embodiments, processes of the present inventionmight be performed by specific hardware components that containhardwired logic for performing the processes, or by any combination ofprogrammed computer components and custom hardware components.

Thus, a machine-readable medium may include any mechanism for storing ortransmitting information in a form readable by a machine (e.g., acomputer), but is not limited to computer-readable storage media such asfloppy diskettes, optical disks, Compact Disc, Read-Only Memories(CD-ROMs), and magneto-optical disks, Read-Only Memories (ROMs), RandomAccess Memories (RAMs), Erasable Programmable Read-Only Memories(EPROMs), Electrically Erasable Programmable Read-Only Memories(EEPROMs), magnetic or optical cards, flash memories, and transmissionmedia such as a transmission over the Internet, electrical, optical,acoustical or other forms of propagated signals (e.g., carrier waves,infrared signals, digital signals, etc.) or the like.

Further, a design may go through various stages, from creation tosimulation to fabrication. Data representing a design may represent thedesign in a number of manners. First, as is useful in simulations, thehardware may be represented using a hardware description language oranother functional description language. Additionally, a circuit levelmodel with logic and/or transistor gates may be produced at some stagesof the design process. Furthermore, most designs, at some stage, reach alevel of data representing the physical placement of various devices inthe hardware model. In the case where conventional semiconductorfabrication techniques are used, data representing a hardware model maybe the data specifying the presence or absence of various features ondifferent mask layers for masks used to produce the integrated circuit.In any representation of the design, the data may be stored in any formof a machine-readable medium. An optical or electrical wave modulated orotherwise generated to transmit such information, a memory, or amagnetic or optical storage such as a disc may be the machine readablemedium. Any of these mediums may “carry” or “indicate” the design orsoftware information. When an electrical carrier wave indicating orcarrying the code or design is transmitted, to the extent that copying,buffering, or re-transmission of the electrical signal is performed, anew copy is made. Thus, a communication provider or a network providermay make copies of an article (a carrier wave) embodying techniques ofthe present invention.

FIG. 1 illustrates one embodiment of a virtual-machine environment 100,in which the present invention may operate. In this embodiment, bareplatform hardware 116 comprises a computing platform, which may becapable, for example, of executing a standard operating system (OS) or avirtual-machine monitor (VMM), such as a VMM 112.

The VMM 112, typically implemented in software, may emulate and export abare machine interface to higher level software. Such higher levelsoftware may comprise a standard or real-time OS, may be a highlystripped-down operating environment with limited operating systemfunctionality, may not include traditional OS facilities, etc.Alternatively, for example, the VMM 112 may be run within, or on top of,another VMM. VMMs may be implemented, for example, in hardware,software, firmware or by a combination of various techniques.

The platform hardware 116 can be of a personal computer (PC), mainframe,handheld device, portable computer, set-top box, or any other computingsystem. The platform hardware 116 includes a processor 118 and memory120.

Processor 118 can be any type of processor capable of executingsoftware, such as a microprocessor, digital signal processor,microcontroller, or the like. The processor 118 may include microcode,programmable logic or hardcoded logic for performing the execution ofmethod embodiments of the present invention. Although FIG. 1 shows onlyone such processor 118, there may be one or more processors in thesystem.

Memory 120 can be a hard disk, a floppy disk, random access memory (RAM)(e.g., dynamic RAM (DRAM) or static RAM (SRAM)), read only memory (ROM),flash memory, any combination of the above devices, or any other type ofmachine medium readable by processor 118. Memory 120 may storeinstructions and/or data for performing the execution of methodembodiments of the present invention.

The VMM 112 presents to other software (i.e., “guest” software) theabstraction of one or more virtual machines (VMs), which may provide thesame or different abstractions to the various guests. FIG. 1 shows twoVMs, 102 and 114. The guest software running on each VM may include aguest OS such as a guest OS 104 or 106 and various guest softwareapplications 108 and 110. Each of the guest OSs 104 and 106 expects toaccess physical resources (e.g., processor registers, memory and I/Odevices) within the VMs 102 and 114 on which the guest OS 104 or 106 isrunning and to perform other functions. For example, the guest OS 104 or106 expects to have access to all registers, caches, structures, I/Odevices, memory and the like, according to the architecture of theprocessor and platform presented in the VM 102 and 114. The resourcesthat can be accessed by the guest software may either be classified as“privileged” or “non-privileged.” For privileged resources, the VMM 112facilitates functionality desired by guest software while retainingultimate control over these privileged resources. Non-privilegedresources do not need to be controlled by the VMM 112 and can beaccessed directly by guest software.

Further, each guest OS expects to handle various fault events such asexceptions (e.g., page faults, general protection faults, etc.),interrupts (e.g., hardware interrupts, software interrupts), andplatform events (e.g., initialization (INIT) and system managementinterrupts (SMIs)). Some of these fault events are “privileged” becausethey must be handled by the VMM 112 to ensure proper operation of VMs102 and 114 and for protection from and among guest software.

When a privileged fault event occurs or guest software attempts toaccess a privileged resource, control may be transferred to the VMM 112.The transfer of control from guest software to the VMM 112 is referredto herein as a VM exit. After facilitating the resource access orhandling the event appropriately, the VMM 112 may return control toguest software. The transfer of control from the VMM 112 to guestsoftware is referred to as a VM entry.

In one embodiment, the processor 118 controls the operation of the VMs102 and 114 in accordance with data stored in a virtual machine controlstructure (VMCS) 125. The VMCS 125 is a structure that may contain stateof guest software, state of the VMM 112, execution control informationindicating how the VMM 112 wishes to control operation of guestsoftware, information controlling transitions between the VMM 112 and aVM, etc. The processor 118 reads information from the VMCS 125 todetermine the execution environment of the VM and to constrain itsbehavior. In one embodiment, the VMCS is stored in memory 120. In someembodiments, multiple VMCS structures are used to support multiple VMs.

During address translation operations, the VM 102 or 114 expects toallocate physical memory, provide protection from and between guestsoftware applications (e.g., applications 108 or 110), use a variety ofpaging techniques, etc. In a non-virtual machine environment, an addresstranslation mechanism expected by an OS may be based on a translationlookaside buffer (TLB) 122 controlled by the processor 118 and atranslation data structure, such as a page-table (PT) hierarchy,controlled by the OS and used to translate virtual memory addresses intophysical memory addresses when paging is enabled.

The architecture of the Intel® Pentium® 4 Processor supports a number ofpaging modes. The most commonly used paging mode supports a 32-bitlinear address space using a two-level hierarchical paging structure(referred to herein as a two-level hierarchy paging mode). Embodimentsof the invention are not limited to this paging mode, but instead may beemployed by one skilled in the art to virtualize other paging modes(e.g., Physical Address Extension (PAE) mode, Intel® Extended Memory 64Technology (EM64T) mode, etc.) and implementations (e.g., hashed pagetables). In one embodiment based on a TLB, translation of a virtualmemory address into a physical memory address begins with searching theTLB 122 using either the upper 20 bits (for a 4 KB page frame) or theupper 10 bits (for a 4 MB page frame) of the virtual address. If a matchis found (a TLB hit), the upper bits of a physical page frame that arecontained in the TLB 122 are conjoined with the lower bits of thevirtual address to form a physical address. The TLB also contains accessand permission attributes associated with the mapping. If no match isfound (a TLB miss), the processor consults the PT hierarchy to determinethe virtual-to-physical translation, which is then cached in the TLB122. Entries in the PT hierarchy may include some attributes that areautomatically set by the processor on certain accesses.

If the PT hierarchy is modified, the TLB 122 may become inconsistentwith the PT hierarchy if a corresponding address translation exists inthe TLB 122. The OS may expect to be able to resolve such aninconsistency by issuing an instruction to the processor 118. Forexample, in the instruction set architecture (ISA) of the Intel®Pentium® 4 (referred to herein as the IA-32 ISA), a processor allowssoftware to invalidate cached translations in the TLB by issuing theINVLPG instruction. In addition, the OS may expect to request theprocessor 118 to change the address space completely, which shouldresult in the removal of all translations from the TLB 122. For example,in the IA-32 ISA, an OS may use a MOV instruction or a task switch torequest a processor to load CR3 (which contains the base address of thePT hierarchy), thereby removing all translations from the TLB. Differentlevels of the page table hierarchy may have different names based uponmode and implementation. In the two-level hierarchy paging mode, thereare two levels of paging structures. The CR3 register points to the baseof the page directory page. Entries in the page directory may eitherspecify a mapping to a large-size page (e.g., a 4 MB superpage, a 2 MBsuperpage, 1 GB superpage, etc.), or a reference to a page table. Thepage table in turn may contain mappings to small-size pages.

As discussed above, in the virtual-machine environment, the VMM 112should be able to have ultimate control over physical resourcesincluding the TLB 122. Embodiments of the present invention address theconflict between the expectations of the VMs 102 and 114 and the role ofthe VMM 112 by using a virtual TLB that emulates the functionality ofthe processor's physical TLB.

The virtual TLB includes the TLB 122 and a set of shadow PT hierarchiescontrolled by the VMM 112. The set of shadow PT hierarchies derive itsformat and content from guest PT hierarchies that may be currently usedor not used by the VM 102 or 114. If the VM 102 or 114 modifies thecontent of the guest PT hierarchies, this content becomes inconsistentwith the content of the shadow PT hierarchies. The inconsistenciesbetween the guest PT hierarchies and the shadow PT hierarchies areresolved using techniques analogous to those employed by the processor118 in managing the TLB 122. Some of these techniques force the VM 102or 114 to issue an event indicating an attempt to manipulate the TLB(e.g., INVLPG, page fault, and load CR3). Such events are privilegedand, therefore, result in a VM exit to the VMM 112. The VMM thenevaluates the event and synchronizes all maintained shadow PThierarchies with the current guest state if needed. We will refer to theset of maintained shadow PT hierarchies as the working set. As multipleprocesses may use the same guest page table, it is possible for the sameshadow PT to be a part of multiple guest PT hierarchies. Thecorresponding shadow PT will in turn be a member of multiple shadow PThierarchies.

Note that synchronization performed by the VMM may update shadow pagetable or page directory entries for a shadow PT hierarchy that is notcurrently in-use. Likewise synchronization may be required to guestpages that are not part of the in-use guest PT hierarchy.

In one embodiment, the VMM 112 includes an address translation module126 that is responsible for creating and maintaining a working set ofshadow PT hierarchies for each of the VM 102 and 114 in a virtual TLB(VTLB) data store 124. The working set of shadow PT hierarchies ismaintained for corresponding active processes of the VM 102 or 114(i.e., processes that are likely to be activated in the near future bythe VM 102 or 114). With the IA32 ISA, the only explicitly defined guesthierarchy is that defined by the currently used paging structures. Inpractice there is a high deal of temporal locality for guest processesand their address spaces. The VMM may employ heuristics or explicitinformation to determine a set of active process.

When the VM 102 or 114 enables a guest PT hierarchy for one of theactive processes of the VM 102 or 114, the address translation module126 identifies a corresponding shadow PT hierarchy in the working setand requests the processor 118 to load its base address. Whenapplicable, the address translation module 126 can then reuse previouslycomputed mappings that are stored in the shadow PT hierarchies.

If the VM 102 or 114 activates a new process, the address translationmodule 126 derives a new shadow PT hierarchy from a corresponding guestPT hierarchy and adds it to the working set. Alternatively, if the VM102 or 114 de-activates an existing process, the address translationmodule 126 removes information corresponding to the guest PT hierarchyfrom the working set.

In one embodiment, the address translation module 126 is responsible forextracting metadata from each new shadow PT hierarchy, storing themetadata in the VTLB data store 124, and updating the metadata when theshadow PT hierarchy is modified. In one embodiment, the metadataincludes a PT vector (PTV), a PD vector (PDV), an active PTE list, andan active PDE list.

The PTV and PDV track the guest frames that are used as PTs and PDs. Inone embodiment, this information is encoded in bit vectors. The PTV maybe indexed by page frame number (PFN), with each entry bit being set ifa corresponding PFN is a PT. The PDV may be indexed by a page framenumber (PFN), with each entry bit being set if a corresponding PFN is aPD.

The active PTE list is a list of PT entries (PTEs) in the shadow PThierarchy that point to frames holding PTs and PD. The active PDE listidentifies PD entries (PDEs) in the shadow PT hierarchy that point toPTs containing PT entries identified in the active PTE list.

In one embodiment, active PDE and PTE lists contain additional metadatadescribing whether the mapping is to a PD or PT frame.

One skilled in the art will understand that embodiments of thisinvention may use a variety of data structures which may be more or lessspace or time efficient than those described herein. One skilled in theart will also recognize the extension of tracking structures to supportadditional paging modes. For example, an EM64T paging mode maps a 64-bitvirtual address to a physical address through a four-level hierarchicalpaging structure. The actual number of bits supported in the virtual orphysical address spaces may be implementation dependent and may be lessthan 64 bits in a particular implementation. As will be discussed inmore detail below, an EM64T implementation may require additions of apage-map level 4 (PML4) page vector and a page directory pointer (PDP)page vector to track the additional page tables used in the EM64T pagingstructure. Likewise, one skilled in the art will recognize that theactive PTE list will be extended to include entries which map any pageused within the paging structures (e.g., PML4 or PDP pages for EM64T).

In one embodiment, active PTE/PDE list metadata is maintained to trackthe number of PD and PT frames that are mapped through a page table.When the number of mappings per page is incremented from 0, then PDEswhich map the PT must be added to the active PDE list, and when thenumber of mappings is decreased to zero, then PDEs that map this PT mustbe removed from the active PDE list.

In one embodiment, the address translation module 126 is responsible forsynchronizing a current shadow PT hierarchy with a current guest PThierarchy when such synchronization is needed. The address translationmodule 126 performs the synchronization by determining which entries inthe guest PT hierarchy have recently been modified and then updatingcorresponding entries in the shadow PT hierarchy accordingly. Theaddress translation module 126 determines which entries in the guest PThierarchy have recently been modified based on the metadata extractedfrom the shadow PT hierarchy and attributes associated with the entriesof the shadow PT hierarchy. In one embodiment, the attributes includeaccess attributes associated with PD entries in the shadow PT hierarchyand update attributes associated with PT entries in the shadow PThierarchy.

FIG. 2 illustrates operation of a virtual TLB 204, according to oneembodiment of the present invention. Virtual TLB 204 includes a shadowtranslation data structure represented by a shadow PT hierarchy 206 anda physical TLB 208. The shadow PT hierarchy 206 derives its structureand content from a guest translation data structure represented by aguest PT hierarchy 202. In one embodiment, the VMM maintains a workingset of shadow PT hierarchies for active processes of the VM.

In one embodiment, when the VM requests the processor to enable adifferent guest PT hierarchy (e.g., by issuing MOV to CR3 or task switchin the IA-32 ISA), control transitions to the VMM, which instructs theprocessor to load the base address 214 of a shadow PT hierarchy 206corresponding to the requested guest PT hierarchy 202. In someembodiments, this shadow PT hierarchy 206 is synchronized with the guestPT hierarchy 202 using relevant metadata and attributes, as will bediscussed in greater detail below.

In one embodiment, the virtual TLB maintains access and updateattributes in the entries of the shadow PD and PTs. These attributes arealso referred to as an accessed (A) bit and a dirty (D) bit. In oneembodiment, when a page frame is accessed by guest software for thefirst time, the processor sets the accessed (A) attribute in thecorresponding PT entry or PD entry in the shadow PT hierarchy 206. Ifguest software attempts to write a page frame, the processor sets thedirty (D) attribute in the corresponding shadow PT entry.

Guest software is allowed to freely modify the guest PT hierarchy 202including changing virtual-to-physical mapping, permissions, etc.Accordingly, the shadow PT hierarchy 206 may not be always consistentwith the guest PT hierarchy 202. When a problem arises from aninconsistency between the hierarchies 202 and 206, the guest OS, whichtreats the virtual TLB 204 as a physical TLB, attempts to change thevirtual TLB 204 by requesting a processor to perform an operationdefined by a relevant ISA. For example, in the IA-32 ISA, suchoperations include the INVLPG instruction, CR3 loads, paging activation(modification of CR0.PG), modification of global paging (toggling of theCR4.PGE bit), etc. The operations attempting to change the virtual TLB204 are configured by the VMM as privileged (e.g., using correspondingexecution controls stored in the VMCS), and, therefore, result in a VMexit to the VMM. The VMM then determines the cause of the VM exit andmodifies the content of the shadow PT hierarchy 206 if necessary. Forexample, if the VM exit occurs due to a page fault that should behandled by the guest OS (e.g., a page fault caused by an access notpermitted by the guest PT hierarchy 202), the page fault is injected tothe guest OS for handling. Alternatively, if the VM exit occurs due to apage fault (or any other operations such as INVLPG) resulting from aninconsistency between the entries of the hierarchies 202 and 206, theVMM may need to remove stale entries, add new entries, or modifyexisting entries, as will be discussed in more detail below. Page faultscaused by the guest PT hierarchy are referred to herein as ‘real’ pagefaults, and page faults that would not have occurred with direct usageof the guest page tables are referred to herein as ‘induced’ pagefaults.

FIG. 3A illustrates a process of creating and maintaining metadata for ashadow PT hierarchy in a two-level hierarchy paging mode, according toone embodiment of the present invention.

Referring to FIG. 3A, a number of physical page frames identified bydistinct letters (letters A through W) is illustrated. Some guest pageframes may contain a PD (e.g., frame A). Other guest page frames maycontain a PT (e.g., frames A, B, C, and L). A hierarchy 302 is a guestPT hierarchy.

FIG. 3A shows a shadow PT hierarchy 304 created based on a guest PThierarchy 302. Each PD or PT in the guest PT hierarchy 302 includes acorresponding PD or PT in the shadow PT hierarchy 304. Note that ingeneral a shadow page is not required for each page in the guest PT.Some embodiments may choose to restrict shadow pages according to usagestatistics (e.g., only generate shadow pages for guest PT pages thathave been used), or according to resource constraints (e.g., maintainingonly a set of shadow pages based on available memory). Separate shadowtables are maintained for PD and PT tables derived from the samephysical frame. For example, separate tables 330 and 332 are maintainedfor PD 306 and PT 308 that are derived from the same physical frame 314.The PD and PT entries in the shadow PT hierarchy 304 contain transformedmappings for the guest frames 314 through 324.

In the guest PT hierarchy 302, frames 316 and 318 are used as PTs 310and 312, and frame 314 is used both as PD 306 and PT 308. This usage isillustrated as “PT” and “PD/PT” in the page frames 314 through 316 shownunder the shadow PT hierarchy 304.

The shadow PT hierarchy 304 is associated with an active PTE list 342and an active PDE list 344. In one embodiment, the active PTE list 342identifies PT entries in the shadow PT hierarchy 304 that map PT and PDpage frames from the guest PT hierarchy 302. In particular, the activePTE list 342 identifies entries in the PT 332 that map page frames 314through 318. In one embodiment, the active PDE list 344 identifies PDentries in the shadow PT hierarchy that point to PTs with entriesidentified in the active PTE list 342. In particular, the active PDElist 344 includes entries in the PD 330 that point to the PT 332. Theactive PTE list 342 and the active PDE list 344 are components of themetadata of the shadow PT hierarchy 304.

The shadow PT hierarchy 304 is associated with a PT bit vector (PTV) 362and a PD bit vector (PDV) 364. In one embodiment, the PTV 362 tracks theguest page frames that are used as PTs. In particular, the PTV 362includes page frames 314 through 318 which are used as PTs in the guestPT hierarchy 302. In one embodiment, the PDV 364 tracks the guest pageframes that are used as PDs. In particular, the PDV 364 includes pageframe 314 that is used as PD in the guest PT hierarchy 302. In oneembodiment, the PTV 362 and PDV 364 represent all shadow PT hierarchiesin the working set and track the capacity in which shadow pages areemployed in the working set (e.g., if a shadow page has not beenallocated for a guest PT, then the PTV will not reflect the guest PTpage, even if it appears in the guest paging structures).

In one embodiment, if the guest OS adds a new PT to the guest PThierarchy 302, the VMM may detect this addition (e.g., on the next orsubsequent VM exit related to TLB manipulation) and add a correspondingPT to the shadow PT hierarchy 304. For example, if a new PT 352 derivedfrom a frame 319 is added to the guest PT hierarchy 302, with a mappingfor a new frame 354, the VMM may add a corresponding PT 360 withtransformed mappings to the shadow PT hierarchy 304 and update themetadata to reflect this change. In particular, the VMM adds an entrymapping frame 319 in the PT 332 to the active PTE list 342, and an entrypointing to the PT 360 in the PD 330 to the active PDE list 344. Also,the VMM adds frame 319 to PTV 362, which tracks guest frames (i.e., hereframe 319) used as PTs.

FIG. 3B illustrates a process of creating and maintaining metadata for ashadow PT hierarchy in the EM64T paging mode, according to oneembodiment of the present invention.

Referring to FIG. 3B, the base of the paging structure is a PML4 page(e.g., frame A). Each entry in the PML4 page may reference a PDP page(e.g., frames B and C). Each entry in the PDP page may reference a pagedirectory (PD) page (e.g., frame D or E), each entry of which in turnmay reference a page in a page table (PT) page (e.g., frame F, G, H orI).

Each PML4, PDP, PD or PT page may be 4 KB in size. In order to supportphysical address spaces larger than 32 bits, the entry size may beincreased relative to the 32-bit paging mode. Specifically, there may be512 entries per page, requiring that 9 bits of the virtual address beused at each level to select the appropriate entry. This selector sizemay lead to a large page size of 2 MB instead of 4 MB as describedpreviously.

In one embodiment, the creation of metadata in the EM64T paging modeincludes the generation of several vectors, an active entry list, andseveral active directory lists. The vectors include a PML4V vectoridentifying frames used as PML4 pages, a PDPV vector identifying framesused as PDP pages, a PDV vector identifying frames used as PD pages, anda PTV vector identifying frames used as PT pages. The active entry listis an active PTE list including all mappings which map a PML4, PDP, PDor PT page. The active directory lists include lists identifying higherlevel mapping structures referencing a lower level structure throughwhich the guest page corresponding to a shadow structure can beaccessed. In particular, the active directory lists consist of an activePDE list including those PDEs that reference a page containing activePTE list entries, an active PDPE list including active PDPE entrieswhich reference a PD containing an active PDE list entry, and an activePML4E list including entries which map a PDP containing elements in theactive PDPE list.

In one embodiment, the synchronization of the shadow page tables beginswith checking each entry in the active PML4E list associated with theused shadow PT hierarchy. If the entry has been accessed, each elementin the active PDPE list corresponding to the accessed PML4 entry ischecked, and then the processing continues as previously described.

In an alternative embodiment, active lists are not maintained and/orprocessed for one or more of the upper levels of the hierarchy. Forexample, in a system in which only a single entry is populated in theuppermost paging structure, the use of an active list for each level ofthe hierarchy will cause this single entry to be always accessed,thereby allowing no reduction in the amount of processing required forlower levels in the hierarchy. To accommodate this usage model, thesynchronization may instead begin by processing an active list lower inthe hierarchy. For example, in one embodiment, active PDPE list elementsmay first be processed followed by active PDE list elements or activePTE list elements associated with a used shadow PT hierarchy. In oneembodiment, the initial layer processed on synchronization may bepredetermined. In another embodiment, the initial layer to be processedmay be determined by dynamic profiling of the guest's page table usage.

Various other paging modes may be used with embodiments of the presentinvention. For example, IA-32 supports an additional paging mode inwhich a 32-bit virtual address is mapped to a larger physical address.In this additional mode of operation, the page table base register isconfigured to point to a PDP page which contains four elements. Entrysizes and behaviors in this additional mode of operations are similar tothose described above for the 64-bit virtual address mode. As thisadditional mode does not make use of PML4 pages, the PML4V and activePML4E list are not required.

FIG. 4 is a flow diagram of one embodiment of a process 400 forsynchronizing a guest translation data structure and a shadowtranslation data structure. The process may be performed by processinglogic that may comprise hardware (e.g., dedicated logic, programmablelogic, microcode, etc.), software (such as that run on a general purposecomputer system or a dedicated machine), or a combination of both. Inone embodiment, the process is performed by an address translationmodule 126 of FIG. 1.

Referring to FIG. 4, process 400 begins with processing logic receivingcontrol transitioned from a VM due to an event pertaining tomanipulation of the TLB (processing block 402). Examples of such eventsmay include a request to change the current address space (e.g., CR3load), a request to adjust inconsistent translations for a specifiedvirtual address in the TLB (e.g., INVLPG), a page fault, etc.

At processing box 404, processing logic determines whether the eventpertaining to the manipulation of the TLB should be handled by the VM.If so (e.g., the event is a page fault caused by a problematic mappingin a guest translation data structure), control is returned to the VMfor handling the event (processing block 406). If not, processing logicdetermines whether the event is associated with a specified problematicaddress (processing box 408).

If the event does not need to be handled by the VM, it may be associatedwith a specified problematic address. Examples of such an event mayinclude an event caused by the INVLPG instruction that takes aproblematic address as an operand, an event caused by an induced pagefault (e.g., a page fault resulting from an inconsistency between thetwo translation data structures with respect to a specific mapping, apage fault caused by a need to virtualize A/D bits in the guesttranslation data structure, etc.), etc. If the event is associated witha specified problematic address, processing logic makes corrections inthe shadow translation data structure for the specified address (e.g.,removes a stale mapping for the specified address or adds a new mappingfor the specified address) to conform to the guest translation datastructure (processing block 410). One embodiment of a process forsynchronizing entries of two translation data structures for a specifiedaddress is discussed in more detail below in conjunction with FIG. 7.

If the event is not associated with any specific address (e.g., theevent is caused by a request of the VM to change the address space,which flushes all TLB entries in IA32), processing logic determineswhich entries of the guest translation data structure have been modified(processing block 412). The determination is made using metadataextracted from the shadow translation data structure and attributesassociated with the entries of the shadow translation data structure(processing block 412). The metadata includes vectors and active listsfor various levels of the shadow translation data structure. A vectorfor a specific level of the shadow translation data structure identifiesframes used as pages at this level of the guest translation datastructure. The active lists include an active entry list and one or moreactive directory lists. The active entry list includes mappings that mappages used by the guest in forming the guest translation data structure.The active directory lists identify higher level mapping structuresreferencing a lower level structure through which a guest pagecorresponding to a shadowed paging structure can be accessed. Asdiscussed above, in the two-level hierarchy paging mode, the metadataincludes, in one embodiment, vectors PTV and PDV, an active entry list(a PTE list), and an active directory list (a PDE list). In the EM64Tpaging mode, the metadata includes, in one embodiment, vectors PTV, PDV,PDPV and PML4V, an active entry list (a PTE list), and active directorylists (an active PDE list, an active PDPE list and an active PML4Elist).

One embodiment of a process for identifying recently modified entries ofthe guest translation data structure using metadata is discussed in moredetail below in conjunction with FIG. 6.

At processing block 414, processing logic synchronizes correspondingentries in the shadow translation data structure with the modifiedentries of the guest translation data structure. Accordingly, processinglogic only needs to synchronize the entries that were modified, ratherthan re-populating the entire content of the shadow translation datastructure.

In one embodiment extra storage is used to maintain some guest PD and/orPT contents as they were last synchronized. This permits the VMM todetermine where modifications have been made without calculating orlooking up additional relocation or permission information.

Note that certain modifications to the guest page tables do not requiremodifications to the shadow page tables. For example, if a guest PTcontains a not present mapping which is subsequently modified, no changeis required to the corresponding shadow PT.

FIGS. 5-14 illustrate various processes performed to support addresstranslation in a virtual machine environment using the two-levelhierarchy paging mode, according to different embodiments of the presentinvention. These processes may be performed by processing logic that maycomprise hardware (e.g., dedicated logic, programmable logic, microcode,etc.), software (such as that run on a general purpose computer systemor a dedicated machine), or a combination of both. In one embodiment,each of these processes is performed by an address translation module126 of FIG. 1.

FIG. 5 is a flow diagram of one embodiment of a process 500 formaintaining metadata for a shadow translation data structure such as ashadow PT hierarchy.

Referring to FIG. 5, process 500 begins with processing logic creating ashadow page for each PD or PT page from the guest PT hierarchy(processing block 502).

At processing block 504, processing logic tracks page frames used as PDsor PTs in the guest PT hierarchy. In one embodiment, processing logicsets an entry in the PDV if a corresponding PFN is a PD in the guest PThierarchy. Similarly, processing logic sets an entry in the PTV if acorresponding PFN is a PT in the guest PT hierarchy.

At processing block 506, processing logic tracks mappings to any DynamicRandom Access Memory (DRAM) backed page (to identify pages that canpotentially be PDs or PTs). In one embodiment, processing logic tracksmappings to DRAM based pages using an inverted page table (IPT) and aninverted page directory (IPD). The IPT is indexed by a PFN of a datapage frame, with each entry containing a list of addresses of PTEs thatmap the data page frame. The IPD is indexed by a PFN of the page table,with each entry containing a list of addresses of PDEs that referencethe PFN as a page table.

In one embodiment, at processing block 508, processing logic identifies4 MB pages in the guest PT hierarchy and creates a page table in theshadow PT hierarchy for each 4 MB page to avoid large page mappings andthereby reduce future synchronization time. Otherwise, an update of a 4MB page would cause the synchronization of every PD and PT page withinthe 4 MB. In one embodiment, an inverted expansion table (IET) is usedto track which PDEs in the guest PT hierarchy point to a 4 MB page. TheIET is indexed by a PFN and attribute bits, with every entry listingPDEs that point to the exploded 4 MB page.

In an embodiment of the invention the IPD may be indexed by the addressof the shadow PFN to minimize required address translation steps.

In IA32, memory type information (e.g., cacheability information) can bestored in PAT bits within the PDE/PTE that maps a page. This typeinformation is not captured in a PDE that is a page-table pointer.Hence, if two 4 MB pages were to map the same region with different PATattributes, then separate page tables would be required to convey thecorrect PAT attributes. Using separate expansion tables for each set ofattributes resolves this issue.

At processing block 510, processing logic identifies PTEs in the shadowPT hierarchy that map pages used as PD or PT in the guest PT hierarchyand creates an active PTE list.

At processing block 512, processing logic identifies PDEs in the shadowPT hierarchy that point to PTs with PTEs identified in the active PTElist and creates an active PDE list.

Subsequently, at processing block 514, if the guest OS modifies thestructure of the guest PT hierarchy (e.g., adds or removes a PD or PT),processing logic changes the above active PTE and PDE lists accordingly.

FIG. 6 is a flow diagram of one embodiment of a process 600 forfacilitating a change of an address space. Note that in IA32 the sameCR3 value may also be reloaded to force a flush of stale TLB mappings.Similar processing steps are taken for a change of CR3 or for a CR3reload.

Referring to FIG. 6, process 600 begins with processing logicdetermining that a VM exit occurred due to a request of the VM to enablea different guest PT hierarchy (e.g., by issuing a CR3 load request)(processing block 602).

In response, processing logic scans all active PDEs corresponding to thecurrently in-use shadow PT hierarchy identified in the active PDE listof the metadata to find which of these PDEs have been accessed (have anaccess attribute set to an access value) (processing block 604), andthen initializes the access attributes of the accessed PDEs (processingblock 606). In IA32, non-leaf paging tables do not support a dirty bit.If the accessed bit is clear, then no page within the 4 MB region hasbeen read or written, so any guest page table or page directory cannothave been modified. However, the accessed bit does not distinguishbetween reads and writes, so 4 MB regions which have been accessedshould be further processed even though it is possible that nothing hasbeen modified. In architectures supporting a dirty bit for non-leaf pagetables, the dirty bit is checked instead, and only regions which hadbeen written to require further processing.

Next, for each accessed PDE, processing logic scans all shadow PTEscorresponding to the accessed active PDE in the active PTE list of themetadata to find which of these PTEs include mappings for an updatedpage (have an update attribute set to an update value) (processing block608).

Further, for each updated page, processing logic compares PD/PT entriesin the guest PT hierarchy with corresponding entries in the shadow PThierarchy (processing block 610) and changes the corresponding entriesof the shadow PT hierarchy to conform to the modified entries of theguest PT hierarchy (e.g., by removing from the shadow PT hierarchy aPTE/PDE absent in the guest PT hierarchy, by adding to the shadow PThierarchy a new PTE/PDE recently added to the guest PT hierarchy, etc.)(processing block 612). Note that adding PDEs may require the allocationand initialization of additional shadow PTs. This in turn may requireupdates to the various metadata structures maintained by the addresstranslation module 126.

At processing block 614, processing logic initializes update attributesthat were set to an update value. Updated mappings identify the pagesthat were modified by the guest OS.

At processing block 616, processing logic synchronizes the shadowmappings based on modified guest pages and updates the metadata ifneeded due to the above modifications.

At processing logic 618, processing logic determines whether a workingset maintained by the VMM includes a shadow PD corresponding to the newguest PD requested by the VM. If so, processing logic requests theprocessor to load the base address of this shadow PT hierarchy(processing block 620). If not, processing logic allocates a new shadowPT hierarchy corresponding to the requested guest PT hierarchy(processing block 622), adds the PD of the new shadow PT hierarchy tothe PDV (processing block 624), adds each valid PDE to the PD of the newshadow PT hierarchy (processing block 626), configures the active PDEand PTE lists to monitor the PTEs that map this PD for PD coverage(processing block 628), and then requests the processor to load the baseaddress of this shadow PT hierarchy (processing block 620). Oneembodiment of a process for monitoring a PTE is discussed in more detailbelow in conjunction with FIG. 13.

FIG. 7 is a flow diagram of one embodiment of a process 700 forsynchronizing entries of two translation data structures for a specifiedaddress. Process 700 may be performed, for example, as a result of theINVLPG instruction issued by the VM or as a result of an induced pagefault.

Referring to FIG. 7, process 700 begins with processing logicdetermining whether the mapping in the shadow PT hierarchy for thespecified address is stale (i.e., there is valid mapping that does notcorrespond to the current contents of the guest page table) (processingbox 702). If not, processing logic proceeds to processing box 712. Ifso, processing logic determines whether the stale entry mapped a PD orPT page (processing box 704). If the stale entry did not map a PD or PTpage, processing logic removes the stale entry (processing block 710)and proceeds to processing box 712.

If the stale entry did map a PD or PT page, processing logic furtherdetermines whether the mapped page has been updated (processing box706). If not, processing logic proceeds to processing block 710. If so,processing logic updates, synchronizes, or removes the modified PD or PTshadow(s) (processing block 708) and proceeds to processing block 710.In one embodiment, the page is marked for future synchronization.

At processing box 712, processing logic determines whether the guest PThierarchy contains a new mapping for the specified address. If not,process 700 ends. If so, processing logic adds the new mapping as acorresponding PTE or PDE and, if necessary, creates a shadow page andupdates the metadata according to the addition (processing block 714).

FIG. 8 is a flow diagram of one embodiment of a process 800 for removinga shadow PT hierarchy from a working set of shadow PT hierarchiesmaintained by the VMM.

A shadow PT hierarchy may be removed from the working set upon detectinga deactivation of a corresponding process by the VM. The deactivationmay be detected using heuristic defined for a relevant OS or employing aset of checks based on clues provided by the behavior of the guest VMwith respect to the current address space. If the VM supports aninterface through which the OS or a driver notifies the VMM ofdeactivations, then a heuristic may be avoided. A shadow PT hierarchymay also be removed due to resource constraints, e.g., because theamount of memory used for shadow structures exceeds a target threshold.

Referring to FIG. 8, processing logic begins with removing each validPDE from the PD in the shadow PT hierarchy (processing block 802).

At processing block 804, processing logic clears a corresponding entryin the PDV.

At processing block 806, processing logic deallocates the PD page andremoves the translation from a PD translation table (PDTT). The PDTT isused to track the address and type (e.g., PD or PT) of a page. The PDTTis indexed by a guest PFN, with each entry containing a physical PFN andmetadata.

At processing block 808, processing logic removes monitoring from thePTEs that map the PD. One embodiment of a process for removingmonitoring from a PTE is discussed in more detail below in conjunctionwith FIG. 14.

FIG. 9 is a flow diagram of one embodiment of a process 900 for addingan entry to a PD of a shadow PT hierarchy. For illustration, we willconsider a present entry which maps a page table.

Referring to FIG. 9, processing logic begins with adding an entry forthe PDE to the IPD (processing block 902).

At processing box 904, processing logic determines if the PT mapped bythis PDE is set in the PTV. If so, the appropriate shadow PT is lookedup in the PTTT (processing block 916), the new shadow PDE is created(processing block 914) and process 900 ends. If not, processing logicsets a corresponding vector in the PTV (processing block 906), allocatesa shadow page and initializes the translation (processing block 908),populates the new shadow page table (processing block 910), updatesactive PTE/PDE lists and metadata to reflect that the guest page used asa page table by the current guest PDE is to be monitored (processingblock 912), and adds the new PDE, adding it to the active PDE list ifthe shadow page table contains any active PTE list elements (processingblock 914). One embodiment of a process for monitoring a PTE isdiscussed in more detail below in conjunction with FIG. 13.

FIG. 10 is a flow diagram of one embodiment of a process 1000 forremoving an entry from a PD of a shadow PT hierarchy.

Referring to FIG. 10, processing logic begins with removing an entry forthis PDE from the IPD PDE list (processing block 1002). If the PDE is inthe active PDE list, then the active PDE list must be updated.

At processing box 1004, processing logic determines whether the PDE wasthe last entry to map the corresponding PT. If not, process 1000 ends.If so, processing logic clears the entry for the PT in the PTV(processing block 1006), removes each valid PTE (processing block 1008),updates the active PTE/PDE lists that map this PT for PT coverage(processing block 1010), and removes the shadow page translation andfree the memory used to store the PT shadow page (processing block1010).

FIG. 11 is a flow diagram of one embodiment of a process 1100 for addingan entry to a PT of a shadow PT hierarchy.

Referring to FIG. 11, processing logic begins with adding an entry forthis PTE to the IPT (processing block 1102).

At processing box 1106, processing logic creates the shadow mapping andproceeds to processing box 1108.

At processing box 1108, processing logic determines whether acorresponding entry in the PDV or PTV is set. If not, process 1100 ends.If so, processing logic adds this entry to the active PTE list andupdates associated metadata indicating if it maps a PD and/or PT page(processing block 1110). If the active PTE entry just created is thefirst for this page table, then the IPD must be consulted and each PDEwhich maps this page table page added to the active PDE list.

FIG. 12 is a flow diagram of one embodiment of a process 1200 forremoving an entry from a PT of a shadow PT hierarchy.

Referring to FIG. 12, processing logic begins with determining whetherthis PTE maps a page set in the PDV or PTV (processing block 1202). Ifnot, processing logic proceeds to processing block 1206. If so,processing logic removes the PTE from the active PTE list. If this wasthe last active PTE list element in the PT, then PDEs referencing thisPT are removed from the active PDE list. (processing block 1204), andproceeds to processing block 1206.

At processing block 1206, processing logic removes the correspondingentry from the IPT.

FIG. 13 is a flow diagram of one embodiment of a process 1300 formonitoring a PTE of a shadow PT hierarchy. The steps shown in FIG. 13represent the processing that may be required when the monitorrecognizes that a page which has been mapped as a data page is beingused as a page directory or page table page. This process will thereforebe triggered by a status change for the page mapped by the PTE.

Referring to FIG. 13, processing logic begins with determining whetherthe PTE is identified in the active PTE list (processing box 1302). Ifso, processing logic adds the previously missing coverage (processingblock 1304). This flow is triggered by a status change of the mappedpage. Since this PTE was already in the active PTE list, it must be thecase that this PTE was previously in use as a PT or PD, and is now inuse in the other capacity as well. Such information may be explicitlystored with the entry or in associated metadata. If the PTE is not inthe active PTE list, processing logic adds the PTE to the active PTElist and updates metadata accordingly (processing block 1306).

Next, at processing box 1308, processing logic determines whether thePTE is the first active PTE list entry for this PT. If not, process 1300ends. If so, processing logic adds, to the active PDE list, entries thatmap this PT (as found through the IPD) (processing block 1310).

FIG. 14 is a flow diagram of one embodiment of a process 1400 fordecreasing the monitoring coverage provided by a PTE of a shadow PThierarchy. This process might be invoked when a process is removed fromthe working set, or the last PDE to reference a page table is removed,resulting in a change of status of a previously monitored page directoryor page table page.

Referring to FIG. 14, processing logic begins with determining whetherthis PTE had monitored a page that was both a page table and pagedirectory page (processing box 1402). If so, processing logic reducesthe coverage level, indicating that the PTE now monitors a page aseither a PT or as a PD, but not both (processing block 1404). If not,processing logic removes the PTE from the active PTE list (processingblock 1406). Note that if the PTE was an element for a page tracked forits use in a single capacity, then it must now be the case that the pageno longer requires monitoring.

Next, if the last active PTE list element in the PT was removed(processing box 1408), processing logic removes the correspondingentries which mapped this page table from the active PDE list (as foundthrough the IPD) (processing block 1410).

As discussed above, the physical or virtual platform may comprisemultiple processors. Each processor may in turn comprise one or morethreads or logical processors. The processes discussed above can be usedin a single-threaded system supporting a single-threaded VM or in aphysical system with multiple logical processors that supports one ormore VMs each containing a single virtual logical processor. Note thateach VM has its own set of metadata, shadow page tables, etc. and thatsynchronization steps are confined to a given VM.

Thus, a method and apparatus for supporting address translation in avirtual machine environment have been described. It is to be understoodthat the above description is intended to be illustrative, and notrestrictive. Many other embodiments will be apparent to those of skillin the art upon reading and understanding the above description. Thescope of the invention should, therefore, be determined with referenceto the appended claims, along with the full scope of equivalents towhich such claims are entitled.

1. A method comprising: receiving control transitioned from a virtualmachine (VM) due to a privileged event pertaining to atranslation-lookaside buffer (TLB); determining which entries in a guesttranslation data structure were modified by the VM, based on metadataextracted from a shadow translation data structure maintained by avirtual machine monitor (VMM) and attributes associated with entries inthe shadow translation data structure; and synchronizing a first set ofthe entries in the shadow translation data structure with the modifiedentries in the guest translation data structure, without processing asecond set of the entries from the shadow translation data structure,wherein the first set of the entries in the shadow translation datastructure includes entries that correspond to the modified entries fromthe guest translation data structure, and the second set of the entriesin the shadow translation data structure includes entries that do notcorrespond to the modified entries from the guest translation datastructure.
 2. The method of claim 1 wherein: the guest translation datastructure is used by the VM for address translation operations; andcontent of the shadow translation data structure is used by a processorto cache address translations in the TLB.
 3. The method of claim 1further comprising: maintaining a working set of shadow translation datastructures, each shadow translation data structure in the working setbeing associated with one of a plurality of active processes of the VM;and reusing content of a shadow translation data structure from theworking set that is associated with one of the plurality of activeprocesses when a guest translation data structure associated with theone of the plurality of active processes is enabled.
 4. The method ofclaim 3 wherein the privileged event is any one of a request of the VMto enable a different guest translation data structure, a page faultcaused by one or more inconsistencies between entries of the guesttranslation data structure and entries of the shadow translation datastructure, and a request of the VM to invalidate one or more addresstranslations in a translation-lookaside buffer (TLB).
 5. The method ofclaim 3 further comprising: determining that the privileged event is anyone of a page fault, an INVLPG instruction, and a request to enable anew guest translation data structure; creating a new shadow translationdata structure based on the new guest translation data structure; andderiving metadata from the new shadow translation data structure.
 6. Themethod of claim 3 further comprising: determining that one of theplurality of the active processes of the VM is deactivated; and removinga shadow translation data structure associated with the active processbeing deactivated from the working set.
 7. The method of claim 3 furthercomprising: determining one of the shadow translation data structures isno longer used; and removing the one of the shadow translation datastructures from the working set.
 8. The method of claim 1 wherein themetadata includes a set of vectors, an active entry list, and one ormore active directory lists.
 9. The method of claim 8 wherein: eachvector in the set identifies frames used as pages at a correspondinglevel of the guest translation data structure; the active entry listidentifies mappings that map pages used in forming the guest translationdata structure for which a shadow translation data structure exists; andthe one or more active directory lists identify higher level mappingstructures referencing a lower level structure through which the shadowtranslation data structure can be accessed.
 10. The method of claim 9wherein: the active entry list is an active page table (PT) entry list,the active PT entry (PTE) list identifying PTEs in the shadowtranslation data structure that map PT pages and PD pages from the guesttranslation data structure, and the one or more active directory listsinclude an active page directory (PD) entry list, the active PD entry(PDE) list identifying PDEs in the shadow translation data structurethat point to PTs having the PTEs from the active PTE list.
 11. Themethod of claim 9 wherein: the active entry list is an active page table(PT) entry list, the active PT entry (PTE) list identifying mappingsthat map any of page map level 4 (PML4) pages, page directory pointer(PDP) pages, page directory (PD) pages, and PT pages; and the one ormore active directory lists include an active PD entry (PDE) listcontaining PDEs that reference a page with active PTE list entries, anactive PDP entry (PDPE) list containing active PDPE entries whichreference a PD with an active PDE list entry, and an active PML4E entry(PML4E) list containing entries which map a PDP with elements from theactive PDPE list.
 12. The method of claim 10 wherein the attributesassociated with entries in the shadow translation data structure includeaccess attributes associated with PDEs in the shadow translation datastructure and update attributes associated with PTEs in the shadowtranslation data structure.
 13. The method of claim 12 whereindetermining which entries in the guest translation data structure weremodified by the VM comprises: identifying one or more PDEs from theactive PDE list corresponding to the active PT hierarchy beingsynchronized that have access attributes set to an access value; and foreach of the identified PDEs, finding corresponding PTEs from the activePTE list that have update attributes set to an update value.
 14. Themethod of claim 13 further comprising: initializing the accessattributes; and initializing the update attributes.
 15. An apparatuscomprising: a guest translation data structure used by a virtual machine(VM) for address translation operations; a shadow translation datastructure maintained by a virtual machine monitor (VMM), the shadowtranslation data structure deriving a format and structure from theguest translation data structure; and an address translation module todetermine, based on metadata extracted from the shadow translation datastructure, which entries in the guest translation data structure weremodified by the VM, and to synchronize a first set of the entries in theshadow translation data structure with the modified entries in the guesttranslation data structure, without processing a second set of theentries from the shadow translation data structure, wherein the firstset of the entries in the shadow translation data structure includesentries that correspond to the modified entries from the guesttranslation data structure, and the second set of the entries in theshadow translation data structure includes entries that do notcorrespond to the modified entries from the guest translation datastructure.
 16. The apparatus of claim 15 wherein the address translationmodule is further to maintain a working set of shadow translation datastructures, each shadow translation data structure in the working setbeing associated with one of a plurality of active processes of the VM,and to reuse content of a shadow translation data structure from theworking set that is associated with one of the plurality of activeprocesses when a guest translation data structure associated with theone of the plurality of active processes is enabled.
 17. The apparatusof claim 16 wherein the privileged event is any one of a request of theVM to enable a different guest translation data structure, a page faultcaused by one or more inconsistencies between entries of the guesttranslation data structure and entries of the shadow translation datastructure, and a request of the VM to invalidate one or more addresstranslations in a translation-lookaside buffer (TLB).
 18. A systemcomprising: a dynamic random access memory (DRAM) to store a guesttranslation data structure used by a virtual machine (VM) for addresstranslation operations, and a shadow translation data structure derivinga format and structure from the guest translation data structure; and aprocessor, coupled to the DRAM, to determine, based on metadataextracted from the shadow translation data structure, which entries inthe guest translation data structure were modified by the VM, and tosynchronize a first set of the entries in the shadow translation datastructure with the modified entries in the guest translation datastructure, without processing a second set of the entries from theshadow translation data structure, wherein the first set of the entriesin the shadow translation data structure includes entries thatcorrespond to the modified entries from the guest translation datastructure, and the second set of the entries in the shadow translationdata structure includes entries that do not correspond to the modifiedentries from the guest translation data structure.
 19. The system ofclaim 18 wherein the processor is further to maintain a working set ofshadow translation data structures, each shadow translation datastructure in the working set being associated with one of a plurality ofactive processes of the VM, and to reuse content of a shadow translationdata structure from the working set that is associated with one of theplurality of active processes when a guest translation data structureassociated with the one of the plurality of active processes is enabled.20. The system of claim 19 wherein the privileged event is any one of arequest of the VM to enable a different guest translation datastructure, a page fault caused by one or more inconsistencies betweenentries of the guest translation data structure and entries of theshadow translation data structure, and a request of the VM to invalidateone or more address translations in a translation-lookaside buffer(TLB).
 21. A computer-readable storage medium storing instructionswhich, when executed by a processing system, cause the processing systemto perform a method, the method comprising: receiving controltransitioned from a virtual machine (VM) due to a privileged eventpertaining to a translation-lookaside buffer (TLB); determining whichentries in a guest translation data structure were modified by the VM,based on metadata extracted from a shadow translation data structuremaintained by a virtual machine monitor (VMM) and attributes associatedwith entries in the shadow translation data structure; and synchronizinga first set of the entries in the shadow translation data structure withthe modified entries in the guest translation data structure, withoutprocessing a second set of the entries from the shadow translation datastructure, wherein the first set of the entries in the shadowtranslation data structure includes entries that correspond to themodified entries from the guest translation data structure, and thesecond set of the entries in the shadow translation data structureincludes entries that do not correspond to the modified entries from theguest translation data structure.
 22. The computer-readable storagemedium of claim 21 wherein the method further comprises: maintaining aworking set of shadow translation data structures, each shadowtranslation data structure in the working set being associated with oneof a plurality of active processes of the VM, and reusing content of ashadow translation data structure from the working set that isassociated with one of the plurality of active processes when a guesttranslation data structure associated with the one of the plurality ofactive processes is enabled.
 23. The computer-readable storage medium ofclaim 22 wherein the privileged event is any one of a request of the VMto enable a different guest translation data structure, a page faultcaused by one or more inconsistencies between entries of the guesttranslation data structure and entries of the shadow translation datastructure, and a request of the VM to invalidate one or more addresstranslations in a translation-lookaside buffer (TLB).